//
//  positionInterfaceViewController.m
//  INAlienLand
//
//  Created by dllo on 15/6/29.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "positionInterfaceViewController.h"
#import "MJRefresh.h"
#import "HTTPTool.h"
#import "positionInterfaceModel.h"
#import "upTableViewCell.h"
#import "UIImageView+WebCache.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface positionInterfaceViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,retain) UITableView *myTableView;

@property (nonatomic,retain) NSMutableArray *titleArr;

@property (nonatomic,retain) NSMutableArray *subtitleArr;

@property (nonatomic,retain) NSMutableArray *pretitleArr;

@property (nonatomic,retain) NSMutableArray *pic_coverArr;

@end

@implementation positionInterfaceViewController

- (void)dealloc
{
   
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"世界";
   
    
   self.titleArr = [NSMutableArray array];
    self.pretitleArr = [NSMutableArray array];
    self.subtitleArr = [NSMutableArray array];
    self.pic_coverArr = [NSMutableArray array];
       [self createData];
    
}
-(void)cratetable
{
    self.myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) style:UITableViewStylePlain];
    [self.view addSubview:self.myTableView];
    [_myTableView release];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    //取消分割线
    self.myTableView.separatorStyle = UITableViewCellSelectionStyleNone;
    

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
   return  1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return self.titleArr.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 85;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        static NSString *reuse = @"reuse";
        upTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
        if (!cell) {
            cell = [[upTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse];
        }
        [cell.leftImageView sd_setImageWithURL:[NSURL URLWithString:self.pic_coverArr[indexPath.section]]];
//    NSLog(@"%@",self.pic_coverArr[indexPath.section]);
        cell.pretitleLabel.text = self.pretitleArr[indexPath.section];
        
        cell.titleLabel.text = self.titleArr[indexPath.section];
        
        cell.subtitleLabel.text = self.subtitleArr[indexPath.section];
        
        return cell;
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.titleArr.count;
}

- (void)createData{
    [HTTPTool get:@"http://icity.2q10.com/api/v1/imsm/world" body:nil HTTPResult:JSON success:^(id result) {
        NSDictionary *dic = result;
        NSDictionary *dic3 = dic[@"data"];
        NSDictionary *dic1 = dic3[@"200300"];
        NSDictionary *dic2 = dic3[@"200900"];
        positionInterfaceModel *model = [[positionInterfaceModel alloc] init];
        [model setValuesForKeysWithDictionary:dic1];
        [model setValuesForKeysWithDictionary:dic2];
     
        [self.titleArr addObject:model.woihxbh[@"title"]];
        [self.titleArr addObject:model.zvaba2y[@"title"]];
        [self.titleArr addObject:model.b6exo696[@"title"]];
        [self.titleArr addObject:model.b86b4uh0[@"title"]];
        [self.titleArr addObject:model.rz4cxd7[@"title"]];
        [self.titleArr addObject:model.sc5jddn[@"title"]];
        [self.titleArr addObject:model.g8xbe83[@"title"]];
        [self.titleArr addObject:model.ydf8efa[@"title"]];
        [self.titleArr addObject:model.iucweh5[@"title"]];
        [self.titleArr addObject:model.xur753k[@"title"]];
        [self.titleArr addObject:model.db8vvar[@"title"]];
        [self.titleArr addObject:model.mkzw4yk[@"title"]];
//        [self.titleArr addObject:model.c7aandf[@"title"]];
        [self.titleArr addObject:model.nqrbobb[@"title"]];
        [self.titleArr addObject:model.b05in4ce[@"title"]];
        [self.titleArr addObject:model.hmhq2q9[@"title"]];
        [self.titleArr addObject:model.b82zv22[@"title"]];
        [self.titleArr addObject:model.b5we625q[@"title"]];
        [self.titleArr addObject:model.gw3tkat[@"title"]];
        [self.titleArr addObject:model.bx3s16q[@"title"]];
        [self.titleArr addObject:model.jlunlgv[@"title"]];
        [self.titleArr addObject:model.b40akjjo[@"title"]];
        [self.titleArr addObject:model.t5lh5fm[@"title"]];
        [self.titleArr addObject:model.eq2jomz[@"title"]];
        [self.titleArr addObject:model.o2j9eo1[@"title"]];
        [self.titleArr addObject:model.f2vsbkt[@"title"]];
        [self.titleArr addObject:model.b1ouexri[@"title"]];
        [self.titleArr addObject:model.r93k10u[@"title"]];
        
        [self.subtitleArr addObject:model.woihxbh[@"subtitle"]];
        [self.subtitleArr addObject:model.zvaba2y[@"subtitle"]];
        [self.subtitleArr addObject:model.b6exo696[@"subtitle"]];
        [self.subtitleArr addObject:model.b86b4uh0[@"subtitle"]];
        [self.subtitleArr addObject:model.rz4cxd7[@"subtitle"]];
        [self.subtitleArr addObject:model.sc5jddn[@"subtitle"]];
        [self.subtitleArr addObject:model.g8xbe83[@"subtitle"]];
        [self.subtitleArr addObject:model.ydf8efa[@"subtitle"]];
        [self.subtitleArr addObject:model.iucweh5[@"subtitle"]];
        [self.subtitleArr addObject:model.xur753k[@"subtitle"]];
        [self.subtitleArr addObject:model.db8vvar[@"subtitle"]];
        [self.subtitleArr addObject:model.mkzw4yk[@"subtitle"]];
//        [self.subtitleArr addObject:model.c7aandf[@"subtitle"]];
        [self.subtitleArr addObject:model.nqrbobb[@"subtitle"]];
        [self.subtitleArr addObject:model.b05in4ce[@"subtitle"]];
        [self.subtitleArr addObject:model.hmhq2q9[@"subtitle"]];
        [self.subtitleArr addObject:model.b86b4uh0[@"subtitle"]];
        [self.subtitleArr addObject:model.b5we625q[@"subtitle"]];
        [self.subtitleArr addObject:model.gw3tkat[@"subtitle"]];
        [self.subtitleArr addObject:model.bx3s16q[@"subtitle"]];
        [self.subtitleArr addObject:model.jlunlgv[@"subtitle"]];
        [self.subtitleArr addObject:model.b40akjjo[@"subtitle"]];
        [self.subtitleArr addObject:model.t5lh5fm[@"subtitle"]];
        [self.subtitleArr addObject:model.eq2jomz[@"subtitle"]];
        [self.subtitleArr addObject:model.o2j9eo1[@"subtitle"]];
        [self.subtitleArr addObject:model.f2vsbkt[@"subtitle"]];
        [self.subtitleArr addObject:model.b1ouexri[@"subtitle"]];
        [self.subtitleArr addObject:model.r93k10u[@"subtitle"]];
        
        [self.pretitleArr addObject:model.woihxbh[@"pretitle"]];
        [self.pretitleArr addObject:model.zvaba2y[@"pretitle"]];
        [self.pretitleArr addObject:model.b6exo696[@"pretitle"]];
        [self.pretitleArr addObject:model.b86b4uh0[@"pretitle"]];
        [self.pretitleArr addObject:model.rz4cxd7[@"pretitle"]];
        [self.pretitleArr addObject:model.sc5jddn[@"pretitle"]];
        [self.pretitleArr addObject:model.g8xbe83[@"pretitle"]];
        [self.pretitleArr addObject:model.ydf8efa[@"pretitle"]];
        [self.pretitleArr addObject:model.iucweh5[@"pretitle"]];
        [self.pretitleArr addObject:model.xur753k[@"pretitle"]];
        [self.pretitleArr addObject:model.db8vvar[@"pretitle"]];
        [self.pretitleArr addObject:model.mkzw4yk[@"pretitle"]];
//        [self.pretitleArr addObject:model.c7aandf[@"pretitle"]];
        [self.pretitleArr addObject:model.nqrbobb[@"pretitle"]];
        [self.pretitleArr addObject:model.b05in4ce[@"pretitle"]];
        [self.pretitleArr addObject:model.hmhq2q9[@"pretitle"]];
        [self.pretitleArr addObject:model.b82zv22[@"pretitle"]];
        [self.pretitleArr addObject:model.b5we625q[@"pretitle"]];
        [self.pretitleArr addObject:model.gw3tkat[@"pretitle"]];
        [self.pretitleArr addObject:model.bx3s16q[@"pretitle"]];
        [self.pretitleArr addObject:model.jlunlgv[@"pretitle"]];
        [self.pretitleArr addObject:model.b40akjjo[@"pretitle"]];
        [self.pretitleArr addObject:model.t5lh5fm[@"pretitle"]];
        [self.pretitleArr addObject:model.eq2jomz[@"pretitle"]];
        [self.pretitleArr addObject:model.o2j9eo1[@"pretitle"]];
        [self.pretitleArr addObject:model.f2vsbkt[@"pretitle"]];
        [self.pretitleArr addObject:model.b1ouexri[@"pretitle"]];
        [self.pretitleArr addObject:model.r93k10u[@"pretitle"]];
        
        [self.pic_coverArr addObject:model.woihxbh[@"pic_cover"]];
        [self.pic_coverArr addObject:model.zvaba2y[@"pic_cover"]];
        [self.pic_coverArr addObject:model.b6exo696[@"pic_cover"]];
        [self.pic_coverArr addObject:model.b86b4uh0[@"pic_cover"]];
        [self.pic_coverArr addObject:model.rz4cxd7[@"pic_cover"]];
        [self.pic_coverArr addObject:model.sc5jddn[@"pic_cover"]];
        [self.pic_coverArr addObject:model.g8xbe83[@"pic_cover"]];
        [self.pic_coverArr addObject:model.ydf8efa[@"pic_cover"]];
        [self.pic_coverArr addObject:model.iucweh5[@"pic_cover"]];
        [self.pic_coverArr addObject:model.xur753k[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.db8vvar[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.mkzw4yk[@"pic_cover"][@"pic"]];
//        [self.pic_coverArr addObject:model.c7aandf[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.nqrbobb[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.b05in4ce[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.hmhq2q9[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.b82zv22[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.b5we625q[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.gw3tkat[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.bx3s16q[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.jlunlgv[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.b40akjjo[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.t5lh5fm[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.eq2jomz[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.o2j9eo1[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.f2vsbkt[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.b1ouexri[@"pic_cover"][@"pic"]];
        [self.pic_coverArr addObject:model.r93k10u[@"pic_cover"][@"pic"]];
        [self.myTableView reloadData];
//        NSLog(@"%ld",self.titleArr.count);
         [self cratetable];
        
        
    } failure:^(NSError *error) {
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
